<template>
	<view class="uni_box home">
		<navbar title='我的项目' backColor="#fff" :backgroundColor="Themecolor">
		</navbar>
		<view class="content">
			<view>
				<text class="xname">项目</text>
				<u-swipe-action :show="item.show" :index="index" 
					v-for="(item, index) in list" :key="item.id" 
					@click="click" @open="open"
					:options="options"
				>
					<view class="item u-border-bottom">
						<image mode="aspectFill" class="listimg" :src="item.images" />
						<!-- 此层wrap在此为必写的，否则可能会出现标题定位错误 -->
						<view class="title-wrap">
							<text class="title u-line-2">{{ item.title }}</text>
							<view class="dfen">
								<text class="dfenitem">Uni</text>
								<text class="dfenitem">Php</text>
							</view>
							<view class="botlistview">
								<text class="qian">¥<text class="qnum">708.00</text></text>
								<text class="bianji">编辑</text>
							</view>
						</view>
					</view>
				</u-swipe-action>
			</view>
			<view class="schuan">
				<view class="scitem" @click="shangchuan">上传项目</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						id: 1,
						title: '长安回望绣成堆，山顶千门次第开，一骑红尘妃子笑，无人知是荔枝来',
						images: 'https://cdn.uviewui.com/uview/common/logo.png',
						show: false
					},
					{
						id: 2,
						title: '新丰绿树起黄埃，数骑渔阳探使回，霓裳一曲千峰上，舞破中原始下来',
						images: 'https://cdn.uviewui.com/uview/common/logo.png',
						show: false
					},
					{
						id: 3,
						title: '登临送目，正故国晚秋，天气初肃。千里澄江似练，翠峰如簇',
						images: 'https://cdn.uviewui.com/uview/common/logo.png',
						show: false,
					}
				],
				disabled: false,
				btnWidth: 180,
				show: false,
				options: [
					// {
					// 	text: '收藏',
					// 	style: {
					// 		backgroundColor: '#007aff'
					// 	}
					// },
					{
						text: '删除',
						style: {
							backgroundColor: this.Themecolor
						}
					}
				]
			}
		},
		onLoad() {
			
		},
		onShow() {
		},
		methods: {
			click(index, index1) {
				if(index1 == 1) {
					this.list.splice(index, 1);
					this.$u.toast(`删除了第${index}个cell`);
				} else {
					this.list[index].show = false;
					this.$u.toast(`收藏成功`);
				}
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.list[index].show = true;
				this.list.map((val, idx) => {
					if(index != idx) this.list[idx].show = false;
				})
			},
			shangchuan(){
				console.log("++=")
				this.navrouter("/pages_subject/twoPage/UploadProject");
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.xname{
		font-size: 40rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #444444;
	}
	.content{
		background-color: #fff;
		padding: 30rpx 30rpx 120rpx;
	}
	.item {
		display: flex;
		padding: 20rpx;
		border-bottom: 1rpx solid #eee;
		.listimg{
			width: 120rpx;
			flex: 0 0 200rpx;
			height: 200rpx;
			margin-right: 20rpx;
			border-radius: 12rpx;
		}
		.title {
			text-align: left;
			color: $u-content-color;
			margin-top: 20rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #000000;
		}
		.dfen{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin: 20rpx 0 0;
			.dfenitem{
				padding: 8rpx 20rpx;
				background: #EEEEEE;
				border-radius: 4rpx;
				margin-right: 20rpx;
				font-size: 20rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #51565D;
			}
			.gone{
				height: 26rpx;
				margin-right: 20rpx;
				width: 108rpx;
			}
			.dmiao{
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #999999;
			}
		}
		.botlistview{
			display: flex;
			flex-direction: row;
			margin-top: 15rpx;
			.qian{
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #111111;
			}
			.qnum{
				font-size: 36rpx;
			}
		}
		.bianji{
			margin-left: auto;
			width: 100rpx;
			height: 50rpx;
			background: $Themecolor;
			border-radius: 6rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}
	.schuan{
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #fff;
		left: 0;
		border-top: 1rpx solid #eee;
		.scitem{
			height: 88rpx;
			background: $Themecolor;
			border-radius: 10rpx;
			width: 94%;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}
	
	
</style>
